package KUOZHAN;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class test6 {
    public static void main(String[] args) {
        List<student> list=new ArrayList<>();
        list.add(new student("迪丽热巴","女",18,99));
        list.add(new student("古力娜扎","女",19,98));
       list.add(new student("周杰伦","男",20,88));
       list.add(new student("蔡徐坤","男",19,78));

        try ( BufferedWriter bf=new BufferedWriter(new FileWriter("Task2.txt",true));){

            for (student student : list) {
                bf.write(student.getName()+","+student.getSex()+","+student.getAge()+","+student.getScore()+"\r\n");

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
